﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AssignmentSWEN3.App_Code;
using System.Data.SqlClient;
using System.Data;

namespace AssignmentSWEN3
{
	public partial class HouseKeepingCreate : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

        protected void Button1_Click(object sender, EventArgs e)
        {
            //the user's inputs
            //for purpose of this lab, we will read only those 
            //inputs that will be displayed in Thank you page.
            int staffOID = (int)Convert.ToInt32(tbxStaffOID.Text);
            string name = tbxName.Text;
            DateTime dob = Convert.ToDateTime(ddlDOBDay.SelectedValue + "/" + ddlDOBMonth.SelectedValue + "/" + tbxDOBYear.Text);
            string bankAccNum = tbxbankAccNum.Text;
            string address = tbxAddress.Text;
            string email = tbxEmail.Text;
            string password = tbxPassword.Text;
            int phoneNum = (int)Convert.ToInt32(tbxContactNum.Text);
            string dutyType = ddlDutyType.SelectedValue;

            string querystring = "staffOID=" + staffOID;
            querystring += "&" + "name=" + name;
            querystring += "&" + "dob=" + dob;
            querystring += "&" + "bankAccNum=" + bankAccNum;
            querystring += "&" + "address=" + address;
            querystring += "&" + "email=" + email;
            querystring += "&" + "password=" + password;
            querystring += "&" + "phone number=" + phoneNum;
            querystring += "&" + "duty type=" + dutyType;

            Staff m = new Staff(staffOID, name, dob, bankAccNum, address, phoneNum, dutyType, email, password);

            if (DataManager.InsertStaff(m) == 1)
            {
                Server.Transfer("HouseKeepingCreateSuccess.aspx?" + querystring);
            }
            else
            {
                lblStatus.Text = "Registration unsuccesful. Please try again";
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("HouseKeepingView.aspx?");
        }
	}
}